from sqlalchemy import Column, String, BigInteger, Integer, DateTime, CHAR
from sqlalchemy.orm import relationship

from app.models.base import BaseModel, SoftDeleteMixin


class Tenant(BaseModel, SoftDeleteMixin):
    """租户模型 - 匹配sys_tenant表结构"""
    __tablename__ = "sys_tenant"

    id = Column(BigInteger, primary_key=True, comment="id")
    tenant_id = Column(String(20), nullable=False, comment="租户编号")
    contact_user_name = Column(String(20), comment="联系人")
    contact_phone = Column(String(20), comment="联系电话")
    company_name = Column(String(50), comment="企业名称")
    license_number = Column(String(30), comment="统一社会信用代码")
    address = Column(String(200), comment="地址")
    intro = Column(String(200), comment="企业简介")
    domain = Column(String(200), comment="域名")
    package_id = Column(BigInteger, comment="租户套餐编号")
    expire_time = Column(DateTime, comment="过期时间")
    account_count = Column(Integer, default=-1, comment="用户数量（-1不限制）")
    status = Column(CHAR(1), default='0', comment="租户状态（0正常 1停用）")


class TenantPackage(BaseModel, SoftDeleteMixin):
    """租户套餐模型 - 匹配sys_tenant_package表结构"""
    __tablename__ = "sys_tenant_package"

    package_id = Column(BigInteger, primary_key=True, comment="租户套餐id")
    package_name = Column(String(20), comment="套餐名称")
    menu_ids = Column(String(3000), comment="关联菜单id")
    menu_check_strictly = Column(Integer, default=1, comment="菜单树选择项是否关联显示")
    status = Column(CHAR(1), default='0', comment="状态（0正常 1停用）")